<!DOCTYPE html>
<html>
<head>
<title>来考试啊！</title>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport" content="width=375">
<meta name="renderer" content="webkit">

<meta http-equiv="Expires" content="0">
<meta http-equiv="Pragma" content="no-cache">
<meta http-equiv="Cache-control" content="no-cache">
<meta http-equiv="Cache" content="no-cache">
<style>
    html {
        height: 100%;
    }
    body {
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: stretch;
        padding: 0 20px;
        margin: 0;
    }
    textarea {
        height: 50%;
        margin: 20px 0;
    }
</style>
<!-- <script src="js/exportData.js"></script> -->

</head>
<body>
    <textarea id="excel"></textarea>
    <div>
        <button id="excel2json">excel => json</button>
    </div>
    <textarea id="json"></textarea>
    <script id="module">
        const $json = document.getElementById('json')
        const $excel = document.getElementById('excel')
        const $excel2json = document.getElementById('excel2json')
    
        $excel2json.onclick = excel2json
    
        function excel2json() {
            let v = $excel.value
            var arr = v.replace(/\s+$/, '').split(/[\n]/g).map( r =>  r.split(/[\t]/g))
            arr = arr.map(r => r.map(i => i.replace(/^\s+|\s+$/, '')))
            arr.map(r => console.log(JSON.stringify(r)))
    
            var Arr = arr.map( r => ({
                q: r[0].replace(/(?<=[（(])\s+(?=[）)])/g, ''),
                b: r.slice(1,5).filter(item => !!item),
                a: r[5]
            }))
    
            $json.value = `var AllDATA = \n ${JSON.stringify(Arr, null, 2)}`
        }
    </script>
</body>
</html>